var t = require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../@babel/runtime/regenerator")), e = require("../../@babel/runtime/helpers/defineProperty"), a = require("../../@babel/runtime/helpers/asyncToGenerator"), n = getApp(), i = (require("../../utils/api.js"), 
require("../../utils/util.js"), require("../../utils/timeUtil.js")), r = require("../../http/activityApi.js");

Page({
    activityId: "",
    timer: null,
    data: {
        systemInfo: n.data.systemInfo,
        resetCycleNumArr: [ "一", "二", "三", "四", "五", "六", "日" ]
    },
    onLoad: function(t) {
        this.activityId = t.activityId;
    },
    onShow: function() {
        this.loadData();
    },
    onHide: function() {},
    onUnload: function() {},
    nothing: function() {},
    gotoUseOnTap: function() {
        wx.reLaunch({
            url: n.homePath
        });
    },
    openGzhRuleOnTap: function() {
        this.setData({
            showGzhRuleDialog: !0
        });
    },
    closeGzhRuleOnTap: function() {
        this.setData({
            showGzhRuleDialog: !1
        });
    },
    closeOpenResultOnTap: function() {
        this.setData({
            openResult: null
        });
    },
    openGzhGiftOnTap: function() {
        var i = this;
        return a(t.default.mark(function a() {
            var o;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    if (1 != i.data.gzhAct.activityCondition || 1 != i.data.gzhAct.umsActivityStatus) {
                        t.next = 3;
                        break;
                    }
                    return n.showConfirm("提示", "需要关注公众号才能领取哦！", function(t) {
                        1 == t && i.gotoFollowGzh();
                    }, !0, "去关注", "取消"), t.abrupt("return");

                  case 3:
                    return t.prev = 3, n.showLoading(), t.next = 7, r.gzhOpen(i.activityId);

                  case 7:
                    o = t.sent, i.setData(e({
                        openResult: o.data
                    }, "gzhAct.opened", !0)), console.log("【公众号】", i.data), t.next = 15;
                    break;

                  case 12:
                    t.prev = 12, t.t0 = t.catch(3), console.log(t.t0);

                  case 15:
                    return t.prev = 15, wx.hideLoading(), t.finish(15);

                  case 18:
                  case "end":
                    return t.stop();
                }
            }, a, null, [ [ 3, 12, 15, 18 ] ]);
        }))();
    },
    loadData: function() {
        var e = this;
        return a(t.default.mark(function a() {
            var o, u;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return t.prev = 0, n.showLoading(), t.next = 4, r.gzhHome(e.activityId);

                  case 4:
                    o = t.sent, u = null, o.data.resetCycleNum && (u = "每周1次领取机会(每周" + e.data.resetCycleNumArr[o.data.resetCycleNum - 1] + "重置)"), 
                    o.data.activityRule = o.data.activityRule.replace(/\<img/gi, '<img class="block"'), 
                    e.setData({
                        inited: !0,
                        title: o.data.activityTitle,
                        gzhAct: {
                            bgImg: o.data.photoMap.bgImg.imgUrl,
                            fgImg: o.data.photoMap.fgImg.imgUrl,
                            bgMiddleImg: o.data.photoMap.act_gzh_middle.imgUrl,
                            rule: o.data.activityRule,
                            timeDesc: u,
                            DangDateLong: new Date().getTime(),
                            StartDateLong: i.timeStringToLong(o.data.startTime),
                            EndDateLong: i.timeStringToLong(o.data.endTime),
                            opened: 1 == o.data.participationStatus,
                            activityCondition: o.data.activityCondition,
                            umsActivityStatus: o.data.umsActivityStatus,
                            rushStatus: o.data.rushStatus
                        }
                    }), t.next = 14;
                    break;

                  case 11:
                    t.prev = 11, t.t0 = t.catch(0), console.log(t.t0);

                  case 14:
                    return t.prev = 14, wx.hideLoading(), t.finish(14);

                  case 17:
                  case "end":
                    return t.stop();
                }
            }, a, null, [ [ 0, 11, 14, 17 ] ]);
        }))();
    },
    gotoFollowGzh: function() {
        return a(t.default.mark(function e() {
            var a, n;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return t.prev = 0, t.next = 3, r.gzhArticleUrl();

                  case 3:
                    a = t.sent, n = a.msg, wx.navigateTo({
                        url: "/pages/webview/webview?title=&url=" + encodeURIComponent(n)
                    }), t.next = 11;
                    break;

                  case 8:
                    t.prev = 8, t.t0 = t.catch(0), console.log(t.t0);

                  case 11:
                  case "end":
                    return t.stop();
                }
            }, e, null, [ [ 0, 8 ] ]);
        }))();
    }
});